﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using Model;
using System.Data.SqlClient;

namespace BLL
{
    public class UsersBLL
    {
        UsersDAL dal = new UsersDAL();

        /// <summary>
        /// 显示用户
        /// </summary>
        /// <returns></returns>
        public List<Users> ShowUsers()
        {
            return dal.Show();
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <returns></returns>
        public List<Users> ShowUsers(string Users_Account, string Users_Pwd)
        {
            SqlParameter[] sp1 = new SqlParameter[]{
                  new SqlParameter("Users_Account",Users_Account),
                  new SqlParameter("Users_Pwd",Users_Pwd)
            };
           //SqlParameter sp = new SqlParameter();
           //sp.ParameterName = "Users_Account";
           // sp.Value = Users_Account;
            return dal.Show(sp1);
        }


        /// <summary>
        /// 查询对应角色的用户
        /// </summary>
        /// <returns></returns>
        public List<Users> ShowUsers(int Roles_id)
        {
            SqlParameter[] sp1 = new SqlParameter[]{
                  new SqlParameter("Roles_id",Roles_id)
            };
            return dal.Show(sp1);
        }


        public List<Users> PaperUsers(int PageIndex, int PageSize, out int PageCount)
        {
            PageCount = dal.Show().Count();
            return dal.Show().Skip((PageIndex - 1) * PageSize).Take(PageSize).ToList();
        }

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool AddUsers(Users m)
        {
            return dal.Add(m);
        }
        /// <summary>
        /// 删除用户
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public bool DelUsers(Users m)
        {
            return dal.Del(m);
        }

        /// <summary>
        /// 查询单个用户信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Users BackUsers(int id)
        {
            return dal.Back(id);
        }

        /// <summary>
        /// 修改用户信息
        /// </summary>
        /// <param name="m"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpdUsers(Users m, int id)
        {
            return dal.Update(m, id);
        }







    }
}
